package com.alvin.demo.utils;

public class NumberUtils {

    // 将整数转化为指定位数的16进制字符串
    public static String longToHexString(Long decimal , int bits) {
        StringBuilder hexString = new StringBuilder(Long.toHexString(decimal));
        if (hexString.length() < bits) {
            int num = bits - hexString.length();
            for (int i = 0; i < num; i++) {
                hexString.insert(0, "0");
            }
        }
        return hexString.toString();
    }

    public static void main(String[] args) {
        System.out.println();
    }
}
